package com.company.huisuo.biz.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import com.company.huisuo.base.BaseSingleAdapter
import com.company.huisuo.biz.bean.RoomStyle
import com.company.huisuo.databinding.ItemServiceStyleBinding
import com.company.huisuo.ext.loadImg


class ServiceStyleAdapter : BaseSingleAdapter<RoomStyle, ItemServiceStyleBinding>() {

    private var mSelectPos = 0

    override val initViewBinding: (LayoutInflater, ViewGroup, Boolean) -> ItemServiceStyleBinding
        get() = ItemServiceStyleBinding::inflate

    override fun convert(
        holder: SingleViewHolder<ItemServiceStyleBinding>, position: Int, item: RoomStyle?
    ) {
        holder.binding.apply {
            tvName.text = item?.styleName ?: ""
            ivAvatar.loadImg(item?.styleCover ?: "")
            tvDesc.text =item?.intro?:""
            viewBg.isSelected = mSelectPos == position
            ivSelect.isSelected = mSelectPos == position
            clLayout.setOnClickListener {
                mSelectPos = position
                notifyDataSetChanged()
            }
        }
    }
}